namespace EFCoreManyToManyDemo;

public class Order
{
    public Order()
    {

    }

    public int Id { get; set; }
    public string Name { get; set; }

    public virtual ICollection<Product> Products { get; set; } = new List<Product>();

    public void AddProduct(string name, string description)
    {
        var product = new Product(this)
        {
            Name = name
        };
        product.SetCategory(name, description);
        Products.Add(product);
    }

    public void SetDescription(int productId, string description)
    {
        var product = Products.First(o => o.Id == productId);
        product.ResetCategory("Reset", description);
    }
}
